package com.h3bpm.web.organization.quartz;

import OThinker.H3.Controller.ControllerBase;
import com.h3bpm.web.organization.service.OrganizationSyncService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/*
 * @author wjq
 * 2019-1-6 14-55
 */
@Component
public class OrganizationQuartz extends ControllerBase {

    private static Logger log = LoggerFactory.getLogger(OrganizationQuartz.class);

    @Autowired
    OrganizationSyncService organizationSyncService;

    @Autowired
    OrganizationSyncService organizationSyncServicece;
    /**
     * 每日数据统计
     */
    //@Scheduled(cron = "0 30 12 * * ?")
    public void updateNoon() {
        log.info("每日中午人事系统更新开始执行,{}");
        String result = organizationSyncService.syncDepartmentService();
        String resultUser =  organizationSyncService.syncUserService();
        String resultManage =  organizationSyncService.syncUserManager();
        try {
            getEngine().getOrganization().Reload();
        } catch (Exception e) {
            e.printStackTrace();
        }
        if("200".equals(result) && "200".equals(resultUser) &&  "200".equals(resultManage) ){
            log.info("每日中午人事系统更新成功,{}");
        }else{
            log.info("每日中午人事系统更新失败,{}");
        }
    }
    /**
     * 每日数据统计
     */
   // @Scheduled(cron = "0 30 0 * * ?")
    public void updateEvening() {
        log.info("每日午夜人事系统更新开始执行,{}");
        String result = organizationSyncService.syncDepartmentService();
        String resultUser =  organizationSyncService.syncUserService();
        String resultManage =  organizationSyncService.syncUserManager();
        try {
            getEngine().getOrganization().Reload();
        } catch (Exception e) {
            e.printStackTrace();
        }
        if("200".equals(result) && "200".equals(resultUser) &&  "200".equals(resultManage) ){
            // return "redirect:/Portal/index.html#/app/HRSystem/BizQueryView/timingSynchronousOrg/timeList/orgSync";
            log.info("每日午夜人事系统更新成功,{}");
        }else{
            log.info("每日午夜人事系统更新失败,{}");
        }
    }
    @Override
    public String getFunctionCode() {
        return null;
    }
}
